﻿<UserControl x:Class="Microsoft.Research.ScientificWorkflow.ManagementStudioControls.RegistryManagerModule.PackagingCenterPaneView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:templateSelectorNs="clr-namespace:Microsoft.Research.ScientificWorkflow.UIDesigner;assembly=Microsoft.Research.ScientificWorkflow.UIDesigner">

    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="boolToVisibilty"/>
        <templateSelectorNs:VisibilityConverter x:Key="VisibilityConverter"/>
        <templateSelectorNs:UniqueIdGenerator x:Key="UniqueIdGenerator"/>
        <templateSelectorNs:PropertyTooltipGenerator x:Key="PropertyTooltipGenerator"/>

        <Style x:Key="TreeViewItemFocusVisual">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Rectangle/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <PathGeometry x:Key="TreeArrow" Figures="M0,0 L0,6 L6,0 z"/>
        <Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="Focusable" Value="False"/>
            <Setter Property="Width" Value="16"/>
            <Setter Property="Height" Value="16"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border Width="16" Height="16" Background="Transparent" Padding="5,5,5,5">
                            <Path Fill="Transparent" Stroke="#FF989898" x:Name="ExpandPath" Data="{StaticResource TreeArrow}">
                                <Path.RenderTransform>
                                    <RotateTransform Angle="135" CenterX="3" CenterY="3"/>
                                </Path.RenderTransform>
                            </Path>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Stroke" TargetName="ExpandPath" Value="#FF1BBBFA"/>
                                <Setter Property="Fill" TargetName="ExpandPath" Value="Transparent"/>
                            </Trigger>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter Property="RenderTransform" TargetName="ExpandPath">
                                    <Setter.Value>
                                        <RotateTransform Angle="180" CenterX="3" CenterY="3"/>
                                    </Setter.Value>
                                </Setter>
                                <Setter Property="Fill" TargetName="ExpandPath" Value="#FF595959"/>
                                <Setter Property="Stroke" TargetName="ExpandPath" Value="#FF262626"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <ControlTemplate x:Key="ListViewItemControlTemplateBasic" TargetType="{x:Type ListViewItem}">
            <Border SnapsToDevicePixels="True" Margin="0,0,0,0" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2,2,2,2">
                <Border x:Name="InnerBorder" BorderThickness="1,1,1,1" CornerRadius="1,1,1,1">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition MaxHeight="11" Height="*"/>
                        </Grid.RowDefinitions>
                        <GridViewRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Grid.RowSpan="1" Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}"/>
                    </Grid>
                </Border>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFF1FBFF" Offset="0"/>
                                <GradientStop Color="#FFD5F1FE" Offset="1"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="BorderBrush" Value="#FFCCF0FF"/>
                </Trigger>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFD9F4FF" Offset="0"/>
                                <GradientStop Color="#FF9BDDFB" Offset="1"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="BorderBrush" Value="#FF98DDFB"/>
                    <Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/>
                </Trigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsSelected" Value="True"/>
                        <Condition Property="Selector.IsSelectionActive" Value="False"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="Background">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFEEEDED" Offset="0"/>
                                <GradientStop Color="#FFDDDDDD" Offset="1"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="BorderBrush" Value="#FFCFCFCF"/>
                </MultiTrigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsSelected" Value="True"/>
                        <Condition Property="IsMouseOver" Value="True"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="Background">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFEAF9FF" Offset="0"/>
                                <GradientStop Color="#FFC9EDFD" Offset="1"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="BorderBrush" Value="#FF98DDFB"/>
                </MultiTrigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        <SolidColorBrush x:Key="ListBorder" Color="#828790"/>

        <!--Listview header style-->
        <Style x:Key="HeaderStyle" TargetType="GridViewColumnHeader">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                        <DockPanel Focusable="False">
                            <Thumb Focusable="False" x:Name="PART_HeaderGripper" Width="2" Opacity="0.2" DockPanel.Dock="Right" Visibility="Visible" />
                            <Border Focusable="False" CornerRadius="0,0,0,0" TextBlock.TextAlignment="Left" Width="{TemplateBinding Width}" BorderThickness="0,1,0,1">
                                <Border.BorderBrush>
                                    <LinearGradientBrush EndPoint="0.5,1.04" StartPoint="0.5,-0.025">
                                        <GradientStop Color="#FFF0F0F0" Offset="0"/>
                                        <GradientStop Color="#FFD5D5D5" Offset="1"/>
                                    </LinearGradientBrush>
                                </Border.BorderBrush>
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,-0.014">
                                        <GradientStop Color="#FFFEFEFE" Offset="0"/>
                                        <GradientStop Color="#FFF6F7F8" Offset="1"/>
                                        <GradientStop Color="#FFFDFDFD" Offset="0.493"/>
                                    </LinearGradientBrush>
                                </Border.Background>
                                <ContentPresenter Focusable="False" Content="{TemplateBinding Content}" VerticalAlignment="Center" Margin="6,0,0,0" />
                            </Border>
                        </DockPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Padding" Value="2"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
        </Style>

        <!--Style for the treeviewitem-->
        <Style TargetType="TreeViewItem">
            <Setter Property="IsExpanded" Value="True"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Padding" Value="1,0,0,0"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <Grid Margin="-5,0,0,0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition MinWidth="19" Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <ToggleButton AutomationProperties.AutomationId="{Binding Path=., Converter={StaticResource UniqueIdGenerator}}" x:Name="Expander" Margin="0,3,0,0" VerticalAlignment="Top" Style="{StaticResource ExpandCollapseToggleStyle}" IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
                            <Border Visibility="{Binding Converter={StaticResource VisibilityConverter}, ConverterParameter=ActivityVisibility}" x:Name="Bd" Background="{TemplateBinding Background}" SnapsToDevicePixels="true" Grid.Column="1" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="16"/>
                                        <ColumnDefinition Width="*" MinWidth="26.098"/>
                                    </Grid.ColumnDefinitions>
                                    <ContentPresenter Margin="2,0,0,0" HorizontalAlignment="Left" x:Name="PART_Header" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header" Grid.ColumnSpan="1" Grid.Column="1"/>
                                    <Image Visibility="{Binding Converter={StaticResource VisibilityConverter}, ConverterParameter=ActivityVisibility}"  Margin="0,4,0,0" Grid.ColumnSpan="1" Source="/Microsoft.Research.ScientificWorkflow.TridentUtilities;component/Images/ScientificWorkflow/workflowFolder.png" Width="12" Height="12" HorizontalAlignment="Center" VerticalAlignment="Top" Stretch="UniformToFill"/>
                                </Grid>
                            </Border>
                            <ItemsPresenter x:Name="ItemsHost" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="false">
                                <Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
                            </Trigger>
                            <Trigger Property="HasItems" Value="false">
                                <Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
                                <Setter Property="Height" TargetName="Expander" Value="0"/>
                            </Trigger>
                            <Trigger Property="HasItems" Value="true">
                                <Setter Property="Visibility" TargetName="Expander" Value="{Binding Converter={StaticResource VisibilityConverter}, ConverterParameter=ActivityVisibility}"/>
                            </Trigger>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Foreground" Value="#FF000000"/>
                                <Setter Property="Background" Value="{x:Null}"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="IsSelectionActive" Value="false"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                            </MultiTrigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!--Name template with the asterisk being dependent on type.-->
        <DataTemplate x:Key="NameTemplate">
            <Grid Margin="0,3,3,0" DockPanel.Dock="Left" HorizontalAlignment="Left">
                <TextBlock Text="{Binding Path=Label}" AutomationProperties.AutomationId="{Binding Path=., Converter={StaticResource UniqueIdGenerator}}"
                       ToolTip="{Binding Converter={StaticResource PropertyTooltipGenerator}, Path=.}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left"/>
            </Grid>
        </DataTemplate>

        <!--Template for showing all the parameters-->
        <HierarchicalDataTemplate x:Key="ParentActivityTemplate" ItemsSource="{Binding Path=Children}">
            <DockPanel Visibility="{Binding Converter={StaticResource VisibilityConverter}, ConverterParameter=ActivityVisibility}" Margin="1,5,0,0">
                <TextBlock DockPanel.Dock="Top" HorizontalAlignment="Left" Text="{Binding Path=Label}" FontWeight="SemiBold"/>
                <ListView DockPanel.Dock="Top" Margin="1,5,0,0" Style="{DynamicResource ListViewStyle1}"
                    ItemsSource="{Binding Path=InputParameters}" IsSynchronizedWithCurrentItem="True"
                    ScrollViewer.HorizontalScrollBarVisibility="Disabled" Initialized="OnListViewInitialized" 
                          Visibility="{Binding Converter={StaticResource VisibilityConverter}, ConverterParameter=ParamVisibility}">
                    <ListView.View>
                        <GridView AllowsColumnReorder="False" ColumnHeaderContainerStyle="{StaticResource HeaderStyle}" >
                            <GridViewColumn Header="Input Parameters" CellTemplate="{StaticResource NameTemplate}" Width="250" />
                        </GridView>
                    </ListView.View>
                </ListView>
                <ListView DockPanel.Dock="Top" Margin="1,5,0,0" Initialized="OnListViewInitialized"
                    ItemsSource="{Binding Path=OutputParameters}" IsSynchronizedWithCurrentItem="True"
                    ScrollViewer.HorizontalScrollBarVisibility="Disabled" Style="{DynamicResource ListViewStyle1}"
                          Visibility="{Binding Converter={StaticResource VisibilityConverter}, ConverterParameter=ParamVisibility}">
                    <ListView.View>
                        <GridView AllowsColumnReorder="False" ColumnHeaderContainerStyle="{StaticResource HeaderStyle}" >
                            <GridViewColumn Header="Output Parameters" CellTemplate="{StaticResource NameTemplate}"  Width="250" />
                        </GridView>
                    </ListView.View>
                </ListView>
            </DockPanel>
        </HierarchicalDataTemplate>

        <!--Style for all the TextBlock-->
        <Style TargetType="{x:Type TextBlock}" >
            <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=Text }"></Setter>
            <Setter Property="TextTrimming" Value="CharacterEllipsis"></Setter>
        </Style>

        <Style x:Key="TabControlStyle2" TargetType="{x:Type TabControl}">
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="Padding" Value="4,4,4,4"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}"/>
            <Setter Property="Background" Value="#F9F9F9"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabControl}">
                        <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="ColumnDefinition0"/>
                                <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition x:Name="RowDefinition0" Height="Auto"/>
                                <RowDefinition x:Name="RowDefinition1" Height="*"/>
                            </Grid.RowDefinitions>
                            <TabPanel Margin="2,2,2,0" x:Name="HeaderPanel" IsItemsHost="true" Panel.ZIndex="1" Grid.Column="0" Grid.Row="0" KeyboardNavigation.TabIndex="1"/>
                            <Border x:Name="ContentPanel" Grid.Column="0" Grid.Row="1" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local" BorderBrush="#FFD4D4D4" CornerRadius="0,4,4,4">
                                <ContentPresenter Margin="{TemplateBinding Padding}" x:Name="PART_SelectedContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="SelectedContent"/>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="TabStripPlacement" Value="Bottom">
                                <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="1"/>
                                <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                                <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                                <Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
                                <Setter Property="Margin" TargetName="HeaderPanel" Value="2,0,2,2"/>
                            </Trigger>
                            <Trigger Property="TabStripPlacement" Value="Left">
                                <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
                                <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                                <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="0"/>
                                <Setter Property="Grid.Column" TargetName="ContentPanel" Value="1"/>
                                <Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
                                <Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
                                <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                                <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                                <Setter Property="Margin" TargetName="HeaderPanel" Value="2,2,0,2"/>
                            </Trigger>
                            <Trigger Property="TabStripPlacement" Value="Right">
                                <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
                                <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                                <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="1"/>
                                <Setter Property="Grid.Column" TargetName="ContentPanel" Value="0"/>
                                <Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
                                <Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
                                <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                                <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                                <Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,2,2"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="InsideTabItemStyle" TargetType="{x:Type TabItem}">
            <Setter Property="FocusVisualStyle" Value="{StaticResource TabItemFocusVisual}"/>
            <Setter Property="Foreground" Value="Black"/>
            <Setter Property="Padding" Value="6,1,6,1"/>
            <Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}"/>
            <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <Grid SnapsToDevicePixels="true" Margin="0,0,3,0">
                            <Border x:Name="Bd" BorderThickness="1,1,1,0" Padding="{TemplateBinding Padding}" CornerRadius="4,4,0,0" BorderBrush="#FFE0E0E0">
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                        <GradientStop Color="#FFF7F7F7" Offset="0"/>
                                        <GradientStop Color="#FFE5E5E5" Offset="1"/>
                                    </LinearGradientBrush>
                                </Border.Background>
                                <Grid x:Name="grid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <ContentPresenter HorizontalAlignment="Stretch" x:Name="Content" VerticalAlignment="Stretch" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header" RecognizesAccessKey="True" Grid.RowSpan="1" Grid.Row="0" Margin="0,2,0,0"/>
                                    <Border Height="4" VerticalAlignment="Top" CornerRadius="3,3,0,0" Background="#FFFFC659" x:Name="border" Margin="-5,0,-5,0" Opacity="0"/>
                                </Grid>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Background" TargetName="Bd" Value="{StaticResource TabItemHotBackground}"/>
                            </Trigger>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Panel.ZIndex" Value="1"/>
                                <Setter Property="Background" TargetName="Bd" Value="{StaticResource TabItemSelectedBackground}"/>
                                <Setter Property="Margin" TargetName="Bd" Value="0,-2,0,-1"/>
                                <Setter Property="Margin" TargetName="border" Value="-5,0,-5,0"/>
                                <Setter Property="Opacity" TargetName="border" Value="1"/>
                                <Setter Property="Margin" TargetName="Content" Value="0,4,0,0"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Grid>
        <Grid.Background>
            <LinearGradientBrush EndPoint="0.5,0.665" StartPoint="0.5,0">
                <GradientStop Color="#FFFFFFFF" Offset="0"/>
                <GradientStop Color="#FFF3F3F3" Offset="1"/>
            </LinearGradientBrush>
        </Grid.Background>

        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CornerRadius="4,4,4,4" 
                BorderThickness="1,1,1,1" Background="#FFFFFFFF" BorderBrush="#FFE0E0E0">
            <Grid Margin="0,0,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="25"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <Border Margin="0,0,0,0" CornerRadius="5,5,0,0" BorderThickness="0,0,0,1" BorderBrush="#FFFFFFFF">
                    <Border.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FFFFFFFF" Offset="0"/>
                            <GradientStop Color="#FFE8E8E8" Offset="1"/>
                        </LinearGradientBrush>
                    </Border.Background>
                    <TextBlock Text="Packages" TextWrapping="Wrap" FontSize="14" FontWeight="Normal" Margin="7,2,0,0"/>
                </Border>

                <Grid VerticalAlignment="Stretch" Grid.Row="1" Margin="10,10,10,10" Grid.RowSpan="2">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" MinHeight="67.104"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <!-- Header -->
                    <Grid HorizontalAlignment="Stretch" Margin="0,0,0,0" Grid.ColumnSpan="1" AutomationProperties.AutomationId="AIDPkgImageGrid">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="72"/>
                            <ColumnDefinition Width="800"/>
                        </Grid.ColumnDefinitions>

                        <Image AutomationProperties.AutomationId="AIDPkgImageGrid_Image" Width="72" HorizontalAlignment="Left" Source="/Microsoft.Research.ScientificWorkflow.TridentUtilities;component/Images/ManagementStudio/packageHeaderPic.png" VerticalAlignment="Top"/>
                        <TextBlock AutomationProperties.AutomationId="AIDPkgImageGrid_Text" ToolTipService.IsEnabled="False" TextAlignment="Justify" VerticalAlignment="Top" Text="Package is a compressed file containing all the related items for an object(e.g. : Workflows). Objects can be packaged and transferred to users at different locations or systems. Packages will be specific to version of the application." TextWrapping="Wrap" Margin="10,0,0,0" Grid.Column="1"/>
                    </Grid>

                    <TabControl Grid.Row="1" Style="{DynamicResource TabControlStyle2}" Margin="0,10,0,0">
                        <TabItem Header="Workflow Details" Style="{DynamicResource InsideTabItemStyle}" AutomationProperties.AutomationId="tabWorkflowDetails">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="40"/>
                                </Grid.RowDefinitions>
                                <ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="50"/>
                                        </Grid.RowDefinitions>

                                        <!-- Workflow Details -->
                                        <Border CornerRadius="5,5,5,5" BorderThickness="1,1,1,1" BorderBrush="#FFD6D6D6" Background="#FFFFFFFF"
                                            Height="Auto" Margin="0,4,0,0" Padding="0,0,0,10">
                                            <Grid AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="125"/>
                                                    <ColumnDefinition Width="*"/>
                                                </Grid.ColumnDefinitions>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                </Grid.RowDefinitions>

                                                <!-- Workflow Name -->
                                                <TextBlock HorizontalAlignment="Right" Text="Workflow Name:" 
                                                       TextWrapping="Wrap" Margin="0,7.5,7.5,0" VerticalAlignment="Top"
                                                       AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_WorkflowNameLabel"/>
                                                <TextBox HorizontalAlignment="Left" Width="300" Text="{Binding Path=WorkflowName, Mode=OneWay}" TextWrapping="Wrap" 
                                                 Margin="0,7.5,7.5,0" Grid.Column="1" VerticalAlignment="Top" x:Name="txtWFName" IsEnabled="False"
                                                 AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_WorkflowNameTextBox"/>

                                                <!-- File Name -->
                                                <TextBlock HorizontalAlignment="Right" Text="File Name:" TextWrapping="Wrap" 
                                                       Grid.Row="1" Margin="0,7.5,7.5,0" VerticalAlignment="Top"
                                                       AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_FileNameLabel"/>
                                                <TextBox x:Name="txtFileName" TextWrapping="Wrap" HorizontalAlignment="Left" Width="300" 
                                                     Margin="0,7.5,7.5,0" VerticalAlignment="Top" Grid.Column="1" Grid.Row="1" IsEnabled="False"
                                                     VerticalScrollBarVisibility="Auto" Grid.RowSpan="1" Text="{Binding Path=WorkflowFileName, Mode=OneWay}"
                                                     AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_FileNameTextBox"/>

                                                <!-- Activities -->
                                                <TextBlock Text="Activities:" TextWrapping="Wrap" Margin="0,7.5,7.5,0" Grid.Row="2"
                                                       VerticalAlignment="Top" HorizontalAlignment="Right"
                                                       AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_ActivitiesLabel"/>
                                                <Border Margin="0,7.5,7.5,0" Grid.Column="1" Grid.Row="2" Grid.RowSpan="1" BorderBrush="#FFD7D7D7"
                                                    BorderThickness="1,1,1,1" HorizontalAlignment="Left" Width="500"
                                                    AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_ActivitiesBorder">
                                                    <TreeView Height="180" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" 
                                                          BorderBrush="#FFD7D7D7" BorderThickness="0"
                                                          x:Name="treeVw" ItemTemplate="{StaticResource ParentActivityTemplate}"
                                                          AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_Activities"/>
                                                </Border>

                                                <!-- Assemblies -->
                                                <TextBlock Text="Assemblies:" TextWrapping="Wrap" Margin="0,7.5,7.5,0" Grid.Row="3"
                                                       VerticalAlignment="Top" HorizontalAlignment="Right"
                                                       AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_AssembliesLabel"/>
                                                <Border Grid.Row="3"  Grid.Column="1" Grid.RowSpan="1" BorderBrush="#FFD7D7D7" BorderThickness="1"
                                                    HorizontalAlignment="Left" Width="500" Margin="0,7.5,7.5,0"
                                                    Visibility="{Binding Converter={StaticResource boolToVisibilty}, Path=DoesNotContainAssemblies}">
                                                    <TextBlock Margin="5,5,5,5" Text="No assemblies available."
                                                           AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_AssembliesList_NoData"/>
                                                </Border>
                                                <ListView IsSynchronizedWithCurrentItem="True" VerticalAlignment="Top" Grid.Column="1" Grid.RowSpan="1"
                                                      ItemsSource="{Binding Path=WorkflowAssembliesCollection}" 
                                                      Visibility="{Binding Converter={StaticResource boolToVisibilty}, Path=ContainAssemblies}"
                                                      BorderBrush="#FFD7D7D7" 
                                                      Style="{DynamicResource ListViewStyle1}" Margin="0,7.5,7.5,0" 
                                                      HorizontalAlignment="Left" Width="500" Height="90" Grid.Row="3" 
                                                      AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_AssembliesList">
                                                    <ListView.View>
                                                        <GridView ColumnHeaderContainerStyle="{StaticResource HeaderStyle}">
                                                            <GridViewColumn Width="450" DisplayMemberBinding="{Binding Path=Name}">
                                                                <GridViewColumn.Header>
                                                                    <TextBlock HorizontalAlignment="Left" Text="Assembly Name" FontWeight="Bold" />
                                                                </GridViewColumn.Header>
                                                            </GridViewColumn>
                                                        </GridView>
                                                    </ListView.View>
                                                </ListView>

                                                <!-- Required Parameters -->
                                                <TextBlock Text="Required Parameters:" TextWrapping="Wrap" VerticalAlignment="Top" 
                                                       HorizontalAlignment="Right" Margin="0,7.5,7.5,0" Grid.Row="4"
                                                       AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_RequiredParametersLabel"/>
                                                <Border Grid.Row="4" Grid.Column="1" BorderBrush="#FFD7D7D7" BorderThickness="1"
                                                    HorizontalAlignment="Left" Width="500" Margin="0,7.5,7.5,0"
                                                    Visibility="{Binding Converter={StaticResource boolToVisibilty}, Path=DoesNotContainRequiredParameters}">
                                                    <TextBlock Margin="5,5,5,5" Text="No workflow required parameter(s) available."
                                                           AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_RequiredParametersList_NoData"/>
                                                </Border>
                                                <ListView IsSynchronizedWithCurrentItem="True" Width="500" Grid.Row="4" Grid.Column="1" 
                                                      ItemsSource="{Binding Path=RequiredParameterCollection}" 
                                                      Visibility="{Binding Converter={StaticResource boolToVisibilty}, Path=ContainRequiredParameters}"
                                                      BorderBrush="#FFD7D7D7" 
                                                      Style="{DynamicResource ListViewStyle1}" HorizontalAlignment="Left" 
                                                      Margin="0,7.5,7.5,0" VerticalAlignment="Top" Height="90" 
                                                      AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_Body_RequiredParametersList">
                                                    <ListView.View>
                                                        <GridView ColumnHeaderContainerStyle="{StaticResource HeaderStyle}">
                                                            <GridViewColumn Width="150" DisplayMemberBinding="{Binding Path=Name}">
                                                                <GridViewColumn.Header>
                                                                    <TextBlock HorizontalAlignment="Left" Text="Name" FontWeight="Bold" />
                                                                </GridViewColumn.Header>
                                                            </GridViewColumn>
                                                            <GridViewColumn Width="150" DisplayMemberBinding="{Binding Path=DataType}">
                                                                <GridViewColumn.Header>
                                                                    <TextBlock HorizontalAlignment="Left" Text="Data Type" FontWeight="Bold" />
                                                                </GridViewColumn.Header>
                                                            </GridViewColumn>
                                                            <GridViewColumn Width="150" DisplayMemberBinding="{Binding Path=Value}">
                                                                <GridViewColumn.Header>
                                                                    <TextBlock HorizontalAlignment="Left" Text="Default Value" FontWeight="Bold" />
                                                                </GridViewColumn.Header>
                                                            </GridViewColumn>
                                                        </GridView>
                                                    </ListView.View>
                                                </ListView>
                                            </Grid>
                                        </Border>

                              
                                    </Grid>
                                </ScrollViewer>
                                <Border Grid.Row="1"  BorderBrush="#FFC1C1C1" BorderThickness="0,1,0,0" Padding="0,10,0,0" AutomationProperties.AutomationId="borderSaveHOst" >
                                    <Grid  HorizontalAlignment="Stretch" VerticalAlignment="Bottom"  Margin="0,0,0,5">
                                        <Button HorizontalAlignment="Right" VerticalAlignment="Top" Width="70" 
                                                Command="{Binding Path=GeneratePackage}" 
                                                x:Name="btnGeneratePackage" Content="Generate" Margin="0,0,90,0" 
                                                AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_ToolBar_GenerateButton"/>
                                        <Button HorizontalAlignment="Right" Width="70" Content="Cancel" 
                                                Command="{Binding Path=Cancel}" 
                                                x:Name="btnCancelPackage" Margin="0,0,10,0" VerticalAlignment="Top" 
                                                AutomationProperties.AutomationId="AIDPkgMainStackPanel_WFDetailsGrid_ToolBar_CancelButton"/>
                                    </Grid>
                                </Border>
                            </Grid>

                        </TabItem>

                        <TabItem Header="MyExperiment" Style="{DynamicResource InsideTabItemStyle}" AutomationProperties.AutomationId="tabMyExperiment">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="40"/>
                                </Grid.RowDefinitions>
                                <ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="30"/>
                                        </Grid.RowDefinitions>

                                        <Border CornerRadius="5,5,5,5" BorderThickness="1,1,1,1" BorderBrush="#FFD6D6D6" Background="#FFFFFFFF"
                                            Height="Auto" Margin="0,2,0,0" Padding="0,0,0,2">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                    <RowDefinition Height="Auto"/>
                                                </Grid.RowDefinitions>

                                                <GroupBox Grid.Row="0" Width="540" Margin="10,5,0,0" HorizontalAlignment="Left">
                                                    <GroupBox.Header>
                                                        <TextBlock Text="myExperiment Account" FontWeight="SemiBold"/>
                                                    </GroupBox.Header>

                                                    <DockPanel LastChildFill="True">
                                                        <StackPanel>
                                                            <Grid Margin="0,5,0,0">
                                                                <Grid.ColumnDefinitions>
                                                                    <ColumnDefinition Width="110"/>
                                                                    <ColumnDefinition Width="*"/>
                                                                </Grid.ColumnDefinitions>

                                                                <TextBlock HorizontalAlignment="Right" Margin="0,0,5,0" VerticalAlignment="Center">
                                                                <Run Text="User name:"/>
                                                                <Run Text="*" Foreground="Red" FontWeight="Bold"/>
                                                                </TextBlock>
                                                                <TextBox Name="txtUserName" AutomationProperties.AutomationId="AIDUserName" Margin="0,0,0,0" HorizontalAlignment="Left" Width="200" Grid.Column="1"/>
                                                            </Grid>

                                                            <Grid Margin="0,7,0,0">
                                                                <Grid.ColumnDefinitions>
                                                                    <ColumnDefinition Width="110"/>
                                                                    <ColumnDefinition Width="*"/>
                                                                </Grid.ColumnDefinitions>

                                                                <TextBlock HorizontalAlignment="Right" Margin="0,0,5,0" VerticalAlignment="Center">
                                                                <Run Text="Password:"/>
                                                                <Run Text="*" Foreground="Red" FontWeight="Bold"/>
                                                                </TextBlock>
                                                                <PasswordBox Name="txtPassword" AutomationProperties.AutomationId="AIDPassword" Margin="0,0,0,0" Width="200" HorizontalAlignment="Left" Grid.Column="1"/>
                                                            </Grid>
                                                        </StackPanel>

                                                        <TextBlock Name="txtMyExperimentLink" AutomationProperties.AutomationId="AIDMyExperimentLink" Focusable="True" Text="Go to myExperiment" TextDecorations="Underline" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Blue" Cursor="Hand" FontSize="12"/>
                                                    </DockPanel>
                                                </GroupBox>

                                                <Grid Margin="0,5,0,0" Grid.Row="1">
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="126"/>
                                                        <ColumnDefinition Width="*"/>
                                                    </Grid.ColumnDefinitions>

                                                    <TextBlock Text="Creator V-Card:" TextWrapping="Wrap" HorizontalAlignment="Right" Margin="0,0,5,0" VerticalAlignment="Center"/>
                                                    <TextBox Name="txtVCard" AutomationProperties.AutomationId="AIDVCard" HorizontalAlignment="Left" Width="300" Grid.Column="1"/>
                                                    <Button Name="btnBrowseVCard" AutomationProperties.AutomationId="AIDBrowseVCard" Width="75" Content="Browse..." HorizontalAlignment="Left" Margin="305,0,0,0" VerticalAlignment="Center" Grid.Column="1"/>
                                                </Grid>

                                                <Grid Margin="0,5,0,0" Grid.Row="2">
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="126"/>
                                                        <ColumnDefinition Width="*"/>
                                                    </Grid.ColumnDefinitions>

                                                    <TextBlock TextWrapping="Wrap" HorizontalAlignment="Right" Margin="0,0,5,0" VerticalAlignment="Center">
                                                    <Run Text="Workflow Image:"/>
                                                    <Run Text="*" Foreground="Red" FontWeight="Bold"/>
                                                    </TextBlock>
                                                    <TextBox Name="txtWorkflowImage" AutomationProperties.AutomationId="AIDWorkflowImage" HorizontalAlignment="Left" Width="300" Grid.Column="1"/>
                                                    <Button Name="btnBrowseWorkflowImage" AutomationProperties.AutomationId="AIDBrowseWorkflowImage" Width="75" Content="Browse..." HorizontalAlignment="Left" Margin="305,0,0,0" VerticalAlignment="Center" Grid.Column="1"/>
                                                </Grid>

                                                <Grid Margin="0,5,0,0" Grid.Row="3">
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="126"/>
                                                        <ColumnDefinition Width="*"/>
                                                    </Grid.ColumnDefinitions>

                                                    <TextBlock Text="Accessibility:" TextWrapping="Wrap" HorizontalAlignment="Right" Margin="0,0,5,0" VerticalAlignment="Center"/>
                                                    <ComboBox Name="cmbAccessibility" AutomationProperties.AutomationId="AIDAccessibility" HorizontalAlignment="Left" Width="300" Grid.Column="1">
                                                        <ComboBoxItem Content="Private" IsSelected="True"/>
                                                        <ComboBoxItem Content="Public"/>
                                                        <ComboBoxItem Content="Download"/>
                                                    </ComboBox>
                                                </Grid>

                                                <GroupBox Grid.Row="4" Margin="10,5,0,0" Width="540" HorizontalAlignment="Left" VerticalAlignment="Stretch">
                                                    <GroupBox.Header>
                                                        <TextBlock Text="Credits" FontWeight="SemiBold"/>
                                                    </GroupBox.Header>

                                                    <StackPanel>
                                                        <Grid Grid.Row="1" Margin="0,0,0,0">
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="110"/>
                                                                <ColumnDefinition Width="*"/>
                                                            </Grid.ColumnDefinitions>

                                                            <TextBlock Text="Credit:" TextWrapping="Wrap" HorizontalAlignment="Right" Margin="0,0,5,0" VerticalAlignment="Center"/>
                                                            <TextBox Name="txtCredits" AutomationProperties.AutomationId="AIDCredits" HorizontalAlignment="Left" VerticalAlignment="Center" Width="300" Grid.Column="1" Grid.ColumnSpan="1"/>
                                                            <Button Name="btnAddCredits" AutomationProperties.AutomationId="AIDAddCredits" IsEnabled="False" Width="75" Content="Add" HorizontalAlignment="Left" Margin="305,0,0,0" VerticalAlignment="Center" Grid.Column="1"/>
                                                        </Grid>

                                                        <ListBox Name="lstCredits" AutomationProperties.AutomationId="AIDCreditsList" Margin="110,7,0,0" Height="67" HorizontalAlignment="Left" VerticalAlignment="Top" Width="380" BorderBrush="#FFC4C4C4"/>
                                                    </StackPanel>
                                                </GroupBox>

                                                <GroupBox Grid.Row="5" Margin="10,5,0,0" Width="540" HorizontalAlignment="Left">
                                                    <GroupBox.Header>
                                                        <TextBlock Text="Attributions" FontWeight="SemiBold"/>
                                                    </GroupBox.Header>

                                                    <StackPanel>
                                                        <Grid Grid.Row="1" Margin="0,0,0,0">
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="110"/>
                                                                <ColumnDefinition Width="*"/>
                                                            </Grid.ColumnDefinitions>

                                                            <TextBlock Text="Attribution:" TextWrapping="Wrap" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0"/>
                                                            <TextBox Name="txtAttributions" AutomationProperties.AutomationId="AIDAttributions" Grid.ColumnSpan="1" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="300"/>
                                                            <Button Name="btnAddAttributions" AutomationProperties.AutomationId="AIDAddAttributions" IsEnabled="False" Width="75" Content="Add" HorizontalAlignment="Left" Grid.Column="1" Margin="305,0,0,0"/>
                                                        </Grid>

                                                        <ListBox Name="lstAttributions" AutomationProperties.AutomationId="AIDAttributionsList" Height="67" Width="380" Margin="110,7,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" BorderBrush="#FFC4C4C4"/>
                                                    </StackPanel>
                                                </GroupBox>
                                            </Grid>
                                        </Border>


                                    </Grid>
                                </ScrollViewer>
                                <!-- Upload/Cancel buttons -->
                                <Border  BorderBrush="#FFC1C1C1" BorderThickness="0,1,0,0" Padding="0,10,0,0" AutomationProperties.AutomationId="borderSaveHOst"  Grid.Row="1">
                                    <Grid  HorizontalAlignment="Stretch" VerticalAlignment="Bottom"  Margin="0,0,0,5">
                                        <Button Name="btnUpload" AutomationProperties.AutomationId="AIDUploadPackage" IsEnabled="False" HorizontalAlignment="Right" VerticalAlignment="Top" Width="70"
                                                Command="{Binding Path=UploadPackage}" Content="Upload" Margin="0,0,90,0"/>
                                        <Button AutomationProperties.AutomationId="AIDCancelUpload" HorizontalAlignment="Right" Width="70" Margin="0,0,10,0" Content="Cancel"
                                                Command="{Binding Path=Cancel}" VerticalAlignment="Top"/>
                                    </Grid>
                                </Border>
                            </Grid>
                        </TabItem>
                    </TabControl>
                </Grid>
            </Grid>
        </Border>
    </Grid>
</UserControl>
